﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ShowEquipment : MonoBehaviour
{
    public static ShowEquipment SE;
    
    public int id;//装备id号
    public Image showImage;
    public Text itemGrade;
    public MainItem mainItem;
    int itemCategory;
    GameObject parent;
    private void Awake()
    {
        SE = this;
        
    }
    private void Start()
    {
        //parent = EquipMentStrengtheningManager.ESM.parentObject;
        //if(id == EquipMentStrengtheningManager.ESM.id)
        //{
        //Debug.Log(VariableDocument.GetInstance.indexInParent);
        //    this.gameObject.transform.GetChild(2).gameObject.SetActive(true);
        //}
    }
    private void Update()
    {
        //Debug.Log(VariableDocument.GetInstance.indexInParent);
    }
    public void AfterClick()
    {
        EquipMentStrengtheningManager.ESM.upStrengthening = false;
        VariableDocument.GetInstance.indexInParent = int.Parse(this.gameObject.name);
        //使所有特效框消失只展示当前
        EquipMentStrengtheningManager.ESM.NNN();
        EquipMentStrengtheningManager.ESM.MMM();
        this.gameObject.transform.GetChild(2).gameObject.SetActive(true);
        //Debug.Log("AfterClick");
        EquipMentStrengtheningManager.ESM.upStrengthening = false;
        EquipMentStrengtheningManager.ESM.id = id;
        itemCategory = mainItem.itemList[id].itemCategory;
        EquipMentStrengtheningManager.ESM.equipmentShowImage.GetComponent<Image>().color = new Color(1, 1, 1, 1);
        EquipMentStrengtheningManager.ESM.equipmentShowImage.GetComponent<Image>().sprite = mainItem.itemList[id].itemImage;
        EquipMentStrengtheningManager.ESM.name1.text = mainItem.itemList[id].itemName;
        EquipMentStrengtheningManager.ESM.name2.text = mainItem.itemList[id].itemName;
        EquipMentStrengtheningManager.ESM.attribute1.text = VariableDocument.GetInstance.equipmentAddText[itemCategory, 0] + ":" +
            mainItem.itemList[id].attribute[VariableDocument.GetInstance.equipmentAddIndex[itemCategory, 0]] + "\n" +
            VariableDocument.GetInstance.equipmentAddText[itemCategory, 1] + ":" +
            mainItem.itemList[id].attribute[VariableDocument.GetInstance.equipmentAddIndex[itemCategory, 1]];
        EquipMentStrengtheningManager.ESM.attribute2.text = VariableDocument.GetInstance.equipmentAddText[itemCategory, 0] + ":" +
            (mainItem.itemList[id].attribute[VariableDocument.GetInstance.equipmentAddIndex[itemCategory, 0]] +
            VariableDocument.GetInstance.upgrade_add_attribute[VariableDocument.GetInstance.equipmentAddIndex[itemCategory, 0]]) + "\n" +
            VariableDocument.GetInstance.equipmentAddText[itemCategory, 1] + ":" +
            (mainItem.itemList[id].attribute[VariableDocument.GetInstance.equipmentAddIndex[itemCategory, 1]] +
            VariableDocument.GetInstance.upgrade_add_attribute[VariableDocument.GetInstance.equipmentAddIndex[itemCategory, 1]]);
        EquipMentStrengtheningManager.ESM.grade1.text = "+" + mainItem.itemList[id].itemGrade;
        EquipMentStrengtheningManager.ESM.grade2.text = "+" + (mainItem.itemList[id].itemGrade + 1);
        EquipMentStrengtheningManager.ESM.needMoney.text = "需要:         " + ((mainItem.itemList[id].itemGrade + 1) * 200);
        EquipMentStrengtheningManager.ESM.btn1.enabled = true;
        EquipMentStrengtheningManager.ESM.btn2.enabled = true;
    }
    public void AfterClick2()
    {
        EquipMentStrengtheningManager.ESM.upStrengthening = false;
        EquipMentStrengtheningManager.ESM.id = id;
        itemCategory = mainItem.itemList[id].itemCategory;
        EquipMentStrengtheningManager.ESM.equipmentShowImage.GetComponent<Image>().color = new Color(1, 1, 1, 1);
        EquipMentStrengtheningManager.ESM.equipmentShowImage.GetComponent<Image>().sprite = mainItem.itemList[id].itemImage;
        EquipMentStrengtheningManager.ESM.name1.text = mainItem.itemList[id].itemName;
        EquipMentStrengtheningManager.ESM.name2.text = mainItem.itemList[id].itemName;
        EquipMentStrengtheningManager.ESM.attribute1.text = VariableDocument.GetInstance.equipmentAddText[itemCategory, 0] + ":" +
            mainItem.itemList[id].attribute[VariableDocument.GetInstance.equipmentAddIndex[itemCategory, 0]] + "\n" +
            VariableDocument.GetInstance.equipmentAddText[itemCategory, 1] + ":" +
            mainItem.itemList[id].attribute[VariableDocument.GetInstance.equipmentAddIndex[itemCategory, 1]];
        EquipMentStrengtheningManager.ESM.attribute2.text = VariableDocument.GetInstance.equipmentAddText[itemCategory, 0] + ":" +
            (mainItem.itemList[id].attribute[VariableDocument.GetInstance.equipmentAddIndex[itemCategory, 0]] +
            VariableDocument.GetInstance.upgrade_add_attribute[VariableDocument.GetInstance.equipmentAddIndex[itemCategory, 0]]) + "\n" +
            VariableDocument.GetInstance.equipmentAddText[itemCategory, 1] + ":" +
            (mainItem.itemList[id].attribute[VariableDocument.GetInstance.equipmentAddIndex[itemCategory, 1]] +
            VariableDocument.GetInstance.upgrade_add_attribute[VariableDocument.GetInstance.equipmentAddIndex[itemCategory, 1]]);
        EquipMentStrengtheningManager.ESM.grade1.text = "+" + mainItem.itemList[id].itemGrade;
        EquipMentStrengtheningManager.ESM.grade2.text = "+" + (mainItem.itemList[id].itemGrade + 1);
        EquipMentStrengtheningManager.ESM.needMoney.text = "需要:         " + ((mainItem.itemList[id].itemGrade + 1) * 200);
        EquipMentStrengtheningManager.ESM.btn1.enabled = true;
        EquipMentStrengtheningManager.ESM.btn2.enabled = true;
    }


    public void ShowLight()
    {
        this.gameObject.transform.GetChild(2).gameObject.SetActive(true);
    }
}
